package org.eae.eldf.service.module.impl;

import java.util.List;

import org.eae.eldf.dao.module.IModuleInfoDao;
import org.eae.eldf.dao.module.impl.ModuleInfoDaoImpl;
import org.eae.eldf.dto.module.ModuleInfoQueryDto;
import org.eae.eldf.entity.module.ModuleInfo;
import org.eae.eldf.framework.pager.Pagination;
import org.eae.eldf.framework.persistence.Criteria;
import org.eae.eldf.framework.service.BaseServiceImpl;
import org.eae.eldf.service.module.ModuleInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
public class ModuleInfoServiceImpl extends BaseServiceImpl<ModuleInfo> implements ModuleInfoService{

	private IModuleInfoDao moduleInfoDao;
	@Autowired
	public void setModuleInfoDao(ModuleInfoDaoImpl moduleInfoDao) {
		this.moduleInfoDao = moduleInfoDao;
		this.dao = moduleInfoDao;
	}
	
	/**
	 * 查询所有的moduleInfo
	 */
	@Override
	public Pagination<ModuleInfo> queryPageModuleList(
			Pagination<ModuleInfo> pager, ModuleInfoQueryDto dto) {
		pager = moduleInfoDao.pageModuleList(pager, dto);
		return pager;
	}
	/**
	 * 插入moduleInfo
	 */
	@Override
	public void insertModule(ModuleInfo module) {
		this.insert(module);
	}
	/**
	 * 通过id删除moduleInfo
	 */
	@Override
	public void delete(Long id) {
		Criteria criteria = Criteria.create(ModuleInfo.class).set("moduleIsDelete", 1).where("moduleInfoId", new Object[]{id});
		moduleInfoDao.update(criteria);
	}
	/**
	 * 通过id查询moduleInfo
	 */
	@Override
	public ModuleInfo queryById(Long id) {
		return moduleInfoDao.get(ModuleInfo.class, id);
	}
	
	
	/**
	 * {@inheritDoc} 
	 * overridden:
	 * @Date        :      2016-7-28
	 * @see org.eae.eldf.service.module.ModuleInfoService#updateModule(org.eae.eldf.framework.persistence.Criteria)
	**/
	@Override
	public void updateModule(Criteria c,Long id) {
		moduleInfoDao.update(c);
	}

	@Override
	public List<ModuleInfo> getCompanyHasModules(String companyCode) {
		return moduleInfoDao.getCompanyHasModules(companyCode);
	}

	@Override
	public List<ModuleInfo> getCompanyNotHasModules(String companyCode) {
		return moduleInfoDao.getCompanyNotHasModules(companyCode);
	}

}
